package main

import (
    "fmt"
    "github.com/micro/go-micro/v2"
    "github.com/micro/go-plugins/wrapper/trace/opentracing/v2"
    "gonaio_base/constant"
    "gonaio_base/rpc/proto_user"
    "gonaio_base/service"
    "gonaio_user_service/handler"
)

func init() {
    s := bservice.New()
    go s.WatchConfig(s.Clear)
}

func main() {
    tracer, closer, err := bservice.New().TraceBoot(bconstant.SERVICE_NAME_USER, bconstant.TRACE_REPORT_HOST_PORT, bconstant.TRACE_REPORT_MAX_PACKET_SIZE)
    if err != nil {
        fmt.Println("链路追踪服务初始化错误")
    }
    defer closer.Close()
    r := bservice.New().GetRegistry()
    s := micro.NewService(
        r,
        micro.Name(bconstant.SERVICE_NAME_USER),
        micro.WrapHandler(opentracing.NewHandlerWrapper(tracer)),
    )
    _ = proto_user.RegisterUserHandler(s.Server(), handler.NewUser())
    s.Init()
    _ = s.Run()
}
